package com.t2c.tibetantochinese.views;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.t2c.tibetantochinese.R;

/**
 * Created by zoulu on 16/6/18.
 * 自定义titlebar
 */
public class TitleBar extends RelativeLayout{

    private RelativeLayout re;
    private ImageView image;
    private TextView title;

    public TitleBar(Context context){
        super(context);
        init(context);
    }

    public TitleBar(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context);
    }

    private void init(Context context){
        LayoutInflater.from(context).inflate(R.layout.titlebar, this);
        re = (RelativeLayout) findViewById(R.id.re);
        image = (ImageView) findViewById(R.id.image);
        title = (TextView) findViewById(R.id.tv_title);

    }

    public void setTitle(String str){
        title.setText(str);
    }

    public TextView getTitle(){
        return title;
    }

    public void setOnLeftListener(OnClickListener listener){
        re.setOnClickListener(listener);
    }

    public void setImageResource(int resID){
        image.setImageResource(resID);
    }

    public void setLeftVisiable(int visibility){
        re.setVisibility(visibility);
    }

}
